package com.parking.status.sync.netty.util;

import com.parking.status.sync.entity.ParkingLot;
import com.parking.status.sync.entity.ParkingStatus;
import com.parking.status.sync.netty.entity.ContentBase;
import com.parking.status.sync.netty.entity.ContentParkingLot;
import com.parking.status.sync.netty.entity.MessageType;

/**
 * Created by Administrator on 2015/9/17.
 */
public class ContentFactory {

    public static ContentBase getContent(Object dbdata) {
        ContentBase ret = null;
        if(dbdata instanceof ParkingLot) {
            ParkingLot parkingLot = (ParkingLot)dbdata;
            ContentParkingLot content = new ContentParkingLot(
                    (short)parkingLot.getTotal_lot(),
                    (short)parkingLot.getTotal_monthly(),
                    (short)parkingLot.getTotal_hourly(),
                    (short)parkingLot.getLeft_lot(),
                    (short)parkingLot.getLeft_monthly(),
                    (short)parkingLot.getLeft_hourly()
            );
            ret = content;
        } else if(dbdata instanceof ParkingStatus) {

        } else {

        }
        return ret;
    }

    public static ContentBase getContent(int messageType, byte[] contentBytes) {
        ContentBase content = null;
        switch (messageType) {
            case MessageType.IN:
                break;
            case MessageType.OUT:
                break;
            case MessageType.PARKINGLOT:
                content = new ContentParkingLot().deserialize(contentBytes);
                break;
            case MessageType.FEESTATE:
                break;
            case MessageType.TIMECHECK:
                break;
            case MessageType.RESPONSE:
                break;
            default:
                break;
        }
        return content;
    }
}
